package com.jn.server;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

public class Student implements Parcelable {
   private String name;
   private int number;
   private String grade;
   private int age;

   public Student(String name, int number, String grade, int age) {
      this.name = name;
      this.number = number;
      this.grade = grade;
      this.age = age;
   }

   protected Student(Parcel in) {
      name = in.readString();
      number = in.readInt();
      grade = in.readString();
      age = in.readInt();
   }

   public static final Creator<Student> CREATOR = new Creator<Student>() {
      @Override
      public Student createFromParcel(Parcel in) {
         return new Student(in);
      }

      @Override
      public Student[] newArray(int size) {
         return new Student[size];
      }
   };

   @Override
   public int describeContents() {
      return 0;
   }

   @Override
   public void writeToParcel(@NonNull Parcel dest, int flags) {
      dest.writeString(name);
      dest.writeInt(number);
      dest.writeString(grade);
      dest.writeInt(age);
   }

   public void readFromParcel(@NonNull Parcel in) {//如果编译报错，添加这个方法，默认没有这个方法
      name = in.readString();
      number = in.readInt();
      grade = in.readString();
      age = in.readInt();
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public int getNumber() {
      return number;
   }

   public void setNumber(int number) {
      this.number = number;
   }

   public String getGrade() {
      return grade;
   }

   public void setGrade(String grade) {
      this.grade = grade;
   }

   public int getAge() {
      return age;
   }

   public void setAge(int age) {
      this.age = age;
   }
}
